package com.zhwl.manage.controller;

import com.zhwl.common.annotation.Log;
import com.zhwl.common.core.controller.BaseController;
import com.zhwl.common.core.domain.AjaxResult;
import com.zhwl.common.enums.BusinessType;
import com.zhwl.common.utils.poi.ExcelUtil;
import com.zhwl.manage.domain.RateTreeCategories;
import com.zhwl.manage.service.IRateTreeCategoriesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 增值税分类Controller
 * 
 * @author mobin
 * @date 2025-07-22
 */
@RestController
@RequestMapping("/manage/categories")
public class RateTreeCategoriesController extends BaseController
{
    @Autowired
    private IRateTreeCategoriesService rateTreeCategoriesService;

    /**
     * 查询增值税分类列表
     */
    @GetMapping("/list")
    public AjaxResult list(RateTreeCategories rateTreeCategories)
    {
        List<RateTreeCategories> list = rateTreeCategoriesService.selectRateTreeCategoriesList(rateTreeCategories);
        return success(list);
    }

    /**
     * 导出增值税分类列表
     */
    @PreAuthorize("@ss.hasPermi('manage:categories:export')")
    @Log(title = "增值税分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RateTreeCategories rateTreeCategories)
    {
        List<RateTreeCategories> list = rateTreeCategoriesService.selectRateTreeCategoriesList(rateTreeCategories);
        ExcelUtil<RateTreeCategories> util = new ExcelUtil<RateTreeCategories>(RateTreeCategories.class);
        util.exportExcel(response, list, "增值税分类数据");
    }

    /**
     * 获取增值税分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:categories:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rateTreeCategoriesService.selectRateTreeCategoriesById(id));
    }

    /**
     * 新增增值税分类
     */
    @PreAuthorize("@ss.hasPermi('manage:categories:add')")
    @Log(title = "增值税分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RateTreeCategories rateTreeCategories)
    {
        return toAjax(rateTreeCategoriesService.insertRateTreeCategories(rateTreeCategories));
    }

    /**
     * 修改增值税分类
     */
    @PreAuthorize("@ss.hasPermi('manage:categories:edit')")
    @Log(title = "增值税分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RateTreeCategories rateTreeCategories)
    {
        return toAjax(rateTreeCategoriesService.updateRateTreeCategories(rateTreeCategories));
    }

    /**
     * 删除增值税分类
     */
    @PreAuthorize("@ss.hasPermi('manage:categories:remove')")
    @Log(title = "增值税分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rateTreeCategoriesService.deleteRateTreeCategoriesByIds(ids));
    }
}
